# 这是一个示例 Python 脚本。
import json

# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。

# 采集百度翻译的结果
import requests

# 按装订区域中的绿色按钮以运行脚本。
if __name__ == '__main__':
    url = 'https://msg.csdn.net/v1/web/message/view/message'
    data = {
        'pageIndex': '2',
        'pageSize': '15',
        'type': '2',
        # 'Content-Type': 'application/json'
    }
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
    'cookie': 'fid=20_63959235291-1727318240850-155824; UN=weixin_49352307; p_uid=U010000; historyList-new=%5B%5D; uuid_tt_dd=10_36630367780-1734491130197-417370; UserName=weixin_49352307; UserInfo=ad328eeb39f341e1816b0800eba56634; UserToken=ad328eeb39f341e1816b0800eba56634; UserNick=Bunury; AU=491; BT=1734501276559; csdn_newcert_weixin_49352307=1; c_dl_fref=https://so.csdn.net/so/search; c_dl_prid=1737007742574_755278; c_dl_rid=1737007745914_388031; c_dl_fpage=/download/u011414042/10300854; c_dl_um=distribute.pc_search_result.none-task-download-2%7Edownload%7Esobaiduweb%7Edefault-0-12768240.269%5Ev2%5Econtrol; FCNEC=%5B%5B%22AKsRol_1EFm1H5MSIZP0BfXO0MswsCJoSjckOWQpzNfXPgNEHoBdfVvx4UvmWdiHsW7VwIh4H7NHFcUbFsuplIc4-jdMHKUaSSwkdFpOIS3znV3mdjmRuyfQJhLGSsEjgaOeumW95YmRhfIqSx2x-ho7JXTGqL3vqA%3D%3D%22%5D%5D; c_segment=10; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1737515808,1737596253,1737708929,1738719616; HMACCOUNT=981C2B72BF990A7F; dc_sid=9283ef52464eb6830d909d5ac2652622; creative_btn_mp=3; _clck=1gks62y%7C2%7Cft6%7C0%7C1730; c_first_ref=www.baidu.com; c_first_page=https%3A//blog.csdn.net/Tank_in_the_street/article/details/121380565; dc_session_id=10_1738740849022.702115; c_dsid=11_1738740856740.400226; SESSION=MmE4MTM3NzItNmEwMi00NDE1LTkwMTQtZDc0ODBjYjQ0MTMz; fe_request_id=1738741915980_4600_9702491; relevant_index=1; c_utm_term=%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%89%8D%E7%AB%AF%20cicd; referrer_search=1738741921225; __gads=ID=385ca7c214ef6166:T=1727318738:RT=1738741921:S=ALNI_MaTuELBBG6sGiLtZwfiCCExG3xndg; __gpi=UID=00000f1e5b614418:T=1727318738:RT=1738741921:S=ALNI_Mbk-t_wSo4J8bwkyP1rx-LoZxMl6A; __eoi=ID=e7f1466e16e80c33:T=1727318738:RT=1738741921:S=AA-AfjZWe10QBcRdrjBDmRsTBM2u; log_Id_click=21; c_utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-6-125270279-blog-143495554.235%5Ev43%5Epc_blog_bottom_relevance_base4; c_utm_relevant_index=9; c_page_id=default; _clsk=1ukj0to%7C1738742093228%7C3%7C0%7Cl.clarity.ms%2Fcollect; c_pref=https%3A//i.csdn.net/; c_ref=https%3A//im.csdn.net/im/main.html; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1738742154; log_Id_view=435; log_Id_pv=19; dc_tos=sr7a4e'
}
# 1.发起请求
r = requests.post(url, json=data, headers=headers)
# 2.打印输出
print(r.json())
# 3.持久化存储
fp = open('./csdn.json', 'w', encoding='utf-8')
json.dump(r.json(), fp, ensure_ascii=False)
